#include "stdafx.h"
#include "CRadioStatu.h"
#include "CESeries.h"
#include "CGraphicMgr.h"
#include "Common.h"
CRadioStatu::CRadioStatu(WCHAR * name):IStatu(name)
{
}

CRadioStatu::~CRadioStatu(void)
{
}

 bool CRadioStatu::ExitStatu()

 {
 
	 return false;

 }                                                
 bool CRadioStatu:: EnterStatu()
 {
	/* m_Status=RADIO_STATUS::FM1_STATUS;
	 CStaticText *p=(CStaticText*)GRAPHICMGR.GetElement(L"txtBand");
	 if (p)
		 p->setvalue(L"FM1");*/
	  g_pSeries->SendCMD_ModeSwitch(MODE::MODE_RADIO);
	 g_pDataMgr->SetModeIndex(MODE::MODE_RADIO);
	 g_FMStatu=RADIO_STATUS::CUR_STATUS;
	 return false;

 }
 bool CRadioStatu::EvaluateClickEvent(const WCHAR* elementName)
 {
	 if (wcscmp(elementName,L"Radio_Band") == 0)
	 { 
	
		
		 g_pSeries->SendCMD_RadioFun(0x01);
		 
         g_FMStatu=RADIO_STATUS::UNKNOW_STATUS;
	
		 return false;

	 }
	 else if (wcscmp(elementName,L"Radio_Manual") == 0)
	 { 
	
		// g_pSeries->SendCMD_RadioFun(0x05);
		 if (m_state!=RADIO_STATUS::MANUAL_STATUS)
		 {

			 m_state=RADIO_STATUS::MANUAL_STATUS;
			 CStaticText* pText=(CStaticText*)GRAPHICMGR.GetElement(L"txtManual");
			 if (pText)
				 pText->setvisible(true);
		 }
		 else
		 {
			 m_state=RADIO_STATUS::UNKNOW_STATUS;
			 CStaticText* pText=(CStaticText*)GRAPHICMGR.GetElement(L"txtManual");
			 if (pText)
				 pText->setvisible(false);
		 }
		 GRAPHICMGR.SetUpdateElements(L"txtManual",L"none");
		 return false;

	 }
	 else if (wcscmp(elementName,L"Radio_FM_FRE0") == 0)
	 { 
		 if (g_BtnDown>1)
		 {
			  g_pSeries->SendCMD_RadioFun(0x0d);
		 }
		 else
		 g_pSeries->SendCMD_RadioFun(0x07);

		 g_FMStatu=RADIO_STATUS::CUR_STATUS;

		 return false;

	 }
	 else if (wcscmp(elementName,L"Radio_FM_FRE1") == 0)
	 { 
		 if (g_BtnDown>1)
		 {
			  g_pSeries->SendCMD_RadioFun(0x0e);
		 }
		 else
		 g_pSeries->SendCMD_RadioFun(0x08);

		 g_FMStatu=RADIO_STATUS::CUR_STATUS;
		 return false;

	 }
	 else if (wcscmp(elementName,L"Radio_FM_FRE2") == 0)
	 { 
		 if (g_BtnDown>1)
		 {
			
		
				 g_pSeries->SendCMD_RadioFun(0x0f);
			
		 }
		 else
		 g_pSeries->SendCMD_RadioFun(0x09);

		 g_FMStatu=RADIO_STATUS::CUR_STATUS;
		 return false;

	 }
	 else if (wcscmp(elementName,L"Radio_FM_FRE3") == 0)
	 { 
		 if (g_BtnDown>1)
		 {
			  g_pSeries->SendCMD_RadioFun(0x10);
		 }
		 else
		 g_pSeries->SendCMD_RadioFun(0x0a);

		 g_FMStatu=RADIO_STATUS::CUR_STATUS;
		 return false;

	 }
	 else if (wcscmp(elementName,L"Radio_FM_FRE4") == 0)
	 { 
		 if (g_BtnDown>1)
		 {
			  g_pSeries->SendCMD_RadioFun(0x11);
		 }
		 else
		 g_pSeries->SendCMD_RadioFun(0x0b);

		 g_FMStatu=RADIO_STATUS::CUR_STATUS;
		 return false;

	 }
	 else if (wcscmp(elementName,L"Radio_FM_FRE5") == 0)
	 { 
		 if (g_BtnDown>1)
		 {
			  g_pSeries->SendCMD_RadioFun(0x12);
		 }
		 else
		 g_pSeries->SendCMD_RadioFun(0x0c);

		 	 g_FMStatu=RADIO_STATUS::CUR_STATUS;
		 RETAILMSG(0, (TEXT("Radio_FM_FRE5_CLick\r\n")));
		 return false;

	 }
	 else if (wcscmp(elementName,L"Radio_AS") == 0)
	 { 
				
		 g_pSeries->SendCMD_RadioFun(0x03);
		 wstring strCurBtn=GlobalStatic::GetRatioGroupValue(L"radio");
		  CButton *p=(CButton*)GRAPHICMGR.GetElement(strCurBtn.c_str());	
		  p->m_bClicked=FALSE;
		   GRAPHICMGR.SetUpdateElements(strCurBtn.c_str(),L"none");
	
	
		 g_FMStatu=RADIO_STATUS::AS_STATUS;

		 return false;

	 }
	 else if (wcscmp(elementName,L"Radio_PS") == 0)
	 { 
		 g_pSeries->SendCMD_RadioFun(0x02);
		   g_FMStatu=RADIO_STATUS::UNKNOW_STATUS;
		 return false;

	 }
	 else if (wcscmp(elementName,L"Radio_next") == 0)
	 { 
		 if(m_state==RADIO_STATUS::MANUAL_STATUS)
			  g_pSeries->SendCMD_RadioFun(0x13);
         else
		 g_pSeries->SendCMD_RadioFun(0x06);

		 return false;

	 }
	 else if (wcscmp(elementName,L"Radio_pre") == 0)
	 { 
		 if(m_state==RADIO_STATUS::MANUAL_STATUS)
			  g_pSeries->SendCMD_RadioFun(0x014);
			 else
		 g_pSeries->SendCMD_RadioFun(0x04);
		 return false;

	 }
	 return false;

 }